.TH E1432_GET_TACH_DELAY 3 E1432
.SH NAME
.nf
e1432_get_tach_delay \- Get the delay time from sytem sync to first sample
.fi
.IX e1432_get_tach_delay(3) 3
.SH SYNOPSIS
.cS
SHORTSIZ16 e1432_get_tach_delay(E1432ID hw, SHORTSIZ16 ID, FLOATSIZ32 *delay)
.cE
.SH DESCRIPTION

\fIe1432_get_tach_delay\fR returns the correction to the tach times such that
they will be expressed relative to the time of the first sample in the 
data FIFO.  The tachometer times are all relative to the time when the system
SYNC line starts a measurement.  Data from the input modules starts filling
the data FIFO at some time after that because of ADC settling times and digital
filter delays.  Adding \fIdelay\fR to the tach times
calculated from the raw tach times returned by \fIe1432_get_raw_tachs\fR 
will yield tach times that are relative to the first sample of data in a
measurement.  Conversely, the negative of \fIdelay\fR is the time between
SYNC and the first sample of data.

\fBNOTE: the first sample
in the FIFO is not the same as the first sample in the first block.\fR  The
first block of data starts after the pre_arm conditions are met.  To
find the number of samples in the FIFO prior to the pre_arm condition, call
the function \fIe1432_get_samples_to_pre_arm\fR.  The number of samples from
pre_arm to
the first sample in each block is found by summing the \fIgap\fR fields found
in the data trailer of each block.

\fIhw\fR must be the result of a successful call to
\fIe1432_assign_channel_numbers\fR, and specifies the group of
hardware to talk to.

\fIID\fR is either the ID of a group of channels that was obtained with a
call to \fIe1432_create_channel_group\fR, or the ID of a single
channel.

\fIdelay\fR is the desired correction in seconds to be added to tach times 
to make them relative to the first sample of data in the FIFO.  

The following sample code shows how to calculate the tach 
time of the first sample in the first block of data:

.cS
    float   delay, tach_correction, span;
    long    pre_arm_samples, gap_sum = 0, count;
    float   data[BLOCK_SIZE];
    struct e1432_trailer trailer;

    e1432_set_append_status(hw, ID, E1432_APPEND_STATUS_ON);

    /* start measurement */

    e1432_get_tach_delay(hw, ID, &delay);
    e1432_get_samples_to_pre_arm(hw, ID, &pre_arm_samples);
    e1432_get_span(hw, ID, &span);

    /* wait for first data block */
    while(e1432_block_available(hw, input) <= 0)
        ; 

    error = e1432_read_float32_data(hw, ID,
        E1432_TIME_DATA, data, BLOCK_SIZE, &trailer, &count);

    /* samples from pre_arm to first in block */
    if (zoom)
    {
        gap_sum += trailer.gap / 2;
        tach_correction = delay -
            (float)(pre_arm_samples + gap_sum) / (1.28 * span);
    }
    else
    {
        gap_sum += trailer.gap;
        tach_correction = delay -
            (float)(pre_arm_samples + gap_sum) / (2.56 * span);
    }
.cE
.SH "RESET VALUE"
0
.SH "RETURN VALUE"
Return 0 if successful, a (negative) error number otherwise.
.SH "SEE ALSO"
.na
e1432_get_raw_tachs, e1432_get_samples_to_pre_arm, e1432_get_append_status
.ad
